import Trips from './Trips/Trips';
import { PlaneManager } from './PlaneManager/PlaneManager';
import { Ground } from './Ground/Ground';
import {
    DesktopOutlined,
    PieChartOutlined,
    YuqueOutlined,
    PlusCircleOutlined
} from '@ant-design/icons';
import { RouteConfig } from '../types';

const PATH_TRIP = '/trip';
const LABEL_TRIP = 'Trip';

const PATH_GROUND = '/ground';
const LABEL_GROUND = 'Ground';

const PATH_PLANE = '/plane/Manage';
const LABEL_PLANE = 'Plane Manage';

export const PATH2LABEL: Record<string, string> = {
    [PATH_TRIP]: LABEL_TRIP,
    [PATH_GROUND]: LABEL_GROUND,
    [PATH_PLANE]: LABEL_PLANE,
}

export const routeConfig: RouteConfig[] = [
    {
        path: PATH_TRIP,
        element: <Trips />,
        label: LABEL_TRIP,
        icon: <PieChartOutlined />,
        permission: ['ward', 'ward1']
    },
    {
        path: PATH_GROUND,
        element: <Ground />,
        label: LABEL_GROUND,
        icon: <DesktopOutlined />,
        permission: ['ward', 'ward1']
    },
    {
        path: '/plane',
        label: 'Plane',
        icon: <YuqueOutlined />,
        permission: ['ward'],
        children: [
            {
                path: PATH_PLANE,
                element: <PlaneManager />,
                label: LABEL_PLANE,
                icon: <PlusCircleOutlined />,
            }
        ]
    }
]

export const getRoutersByUsername = (username?: string) => {
    if (!username) return [];
    return routeConfig.filter(({ permission }) => {
        if (!permission) return true;
        return permission.includes(username);
    })
}
